﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Vms.DB;
using Vms.Business;
using System.Text;
using System.IO;

public partial class Xoso : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DB m_db = new DB();
        Util m_util = new Util();
        WriteFile wf = new WriteFile();
        try
        {
            string str = "";
            int service_id = 0;
            Util.TSession m_tSession = new Util.TSession();
            m_tSession.UserMSISDN = m_util.GetHeaderValue(Request.Headers, "User-MSISDN");
            m_tSession.User_ID = m_util.GetHeaderValue(Request.Headers, "User-UID");
            m_tSession.ServiceList = "2";
            m_tSession.KeyPress = "2";
            m_tSession.SessionID = "";
            m_tSession.IP = "";
            m_db.UpdateReQuestTbl(m_tSession);
            str = "<?xml version='1.0' encoding='ISO-8859-1'?>" +
                   "<!DOCTYPE pages SYSTEM 'cellflash.dtd'>" +
                   "<pages descr='Samis'>" +
                   "<page>";
            if (Request.Params["cid"] != null)
            {
                service_id = Int32.Parse(Request.Params["cid"]);
            }



            DataSet ds = new DataSet();
            ds = m_db.GetServiceByPage(service_id);
            DataTable dtb = new DataTable();
            dtb = ds.Tables[0].Clone();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                dtb.Rows.Add(ds.Tables[0].Rows[i].ItemArray);
            }
            foreach (DataRow dr in dtb.Rows)
            {
                str += "<a href='Xoso_KetQua.aspx?service_id=" + dr["Service_ID"].ToString() + "&Tinhid=0'>" + dr["text"].ToString().Trim() + "</a><br/>";
            }

            str += "</page>" +
                    "</pages>";
            Response.ClearHeaders();
            Response.AddHeader("content-type", "text/xml");
            Response.Write(str);
            wf.WriteStreamFile(str);
            Response.End();
        }
        catch (Exception ex)
        {
            wf.WriteError(ex.ToString());
        }
    }
}